import request from "@/utils/request";

function page(current, size) {
    return request({
        method: 'GET',
        url: '/course/page',
        params: {
            current: current,
            size: size,
        }
    });
}

function get_all() {
    return request({
        method: 'GET',
        url: '/course/list',
    });
}

function add(name, credits, category, semesterId, assessmentMethod, startWeek,
    endWeek, totalHours, selectionMethod
) {
    return request({
        method: 'POST',
        url: '/course',
        data: {
            name: name,
            credits: credits,
            category: category,
            semesterId: semesterId,
            assessmentMethod: assessmentMethod,
            startWeek: startWeek,
            endWeek: endWeek,
            totalHours: totalHours,
            selectionMethod: selectionMethod,
        }
    });
}

function edit(id, name, credits, category, semesterId, assessmentMethod, startWeek,
    endWeek, totalHours, selectionMethod
) {
    return request({
        method: 'PUT',
        url: '/course',
        data: {
            id: id,
            name: name,
            credits: credits,
            category: category,
            semesterId: semesterId,
            assessmentMethod: assessmentMethod,
            startWeek: startWeek,
            endWeek: endWeek,
            totalHours: totalHours,
            selectionMethod: selectionMethod,
        }
    });
}

function del(id) {
    return request({
        method: 'DELETE',
        url: `/course/${id}`,
    });
}

export default {
    page,
    get_all,
    add,
    edit,
    del,
}